{% extends "sharkdata_base.html" %}

{% block title %}SHARKdata - Data administration{% endblock %}

{% block header %}Data administration{% endblock %}

{% block content %}

    <!-- Alert alternatives: alert-success, alert-info, alert-warning, alert-danger -->
    <div class="alert alert-info">
        Note: You should be a registered administrator to run the commands on this page.
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="panel-title">Datasets</span>
        </div>
        <div class="panel-body">
        <p>
            It is possible for administrators to upload datasets via SFTP.
            Use the commands below to synchronise the SHARKdata database with the content in the FTP-area.<br>
            To delete a single dataset select the rightmost column on the <a href="/datasets/">Datasets</a> page.
        </p>
        <p>
<!--            <a class="btn btn-sm btn-default" href="/sharkdataadmin/datasets_import">Import new dataset</a> -->
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/datasets_delete_all">Delete all datasets</a>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/datasets_load_all">Update from FTP-area</a>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/generate_archives">Generate archives</a>
        </p>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="panel-title">Resources</span>
        </div>
        <div class="panel-body">
        <p>
            It is possible for administrators to upload resource files via SFTP.
            Use the commands below to synchronise the SHARKdata database with the content in the FTP-area.<br>
            To delete a single resource select the rightmost column on the <a href="/resources/">Resources</a> page.
        </p>
        <p>
<!--            <a class="btn btn-sm btn-default" href="/sharkdataadmin/resources_import">Import new resource</a> -->
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/resources_delete_all">Delete all resources</a>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/resources_load_all">Update from FTP-area</a>
        </p>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="panel-title">Species observations</span>
        </div>
        <div class="panel-body">
        <p>
            Species observation data are extracted from data stored in the datasets.  
            Use the commands below to synchronise species observations with the loaded datasets.
        </p>
        <p>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/speciesobs_update">Update from datasets</a>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/speciesobs_load">Reload from backup file</a>
            <a class="btn btn-sm btn-default" href="/sharkdataadmin/speciesobs_cleanup">Clean up DB</a>
        </p>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="panel-title">Executed commands</span> <a href="/sharkdataadmin">Update list</a>
            
        </div>

        <div class="table-container">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Command</th>
                        <th>Status</th>
                        <th>Started</th>
                        <th>Finished</th>
                        <th>Result log</th>
<!--                        <th>Mail to admin(s):</th> -->
                    </tr>
                </thead>
                <tbody>
                {% for logrow in logrows %}
                    <tr>
                        <td>{{ logrow.command_name }}</td>
                        <td>{{ logrow.status }}</td>
                        <td>{{ logrow.started_datetime | date:'Y-m-d H:i:s' }}</td>
                        <td>{{ logrow.finished_datetime | date:'Y-m-d H:i:s' }}</td>
                        <td><a class="btn btn-primary btn-xs" href="/sharkdataadmin/view_log/{{ logrow.id }}">View result</a></td>
<!--                        <td><a class="btn btn-primary btn-xs" href="/sharkdataadmin/mail_log/{{ logrow.id }}">Mail</a></td> -->
<!--                        <td><a class="btn btn-primary btn-xs" href="/sharkdataadmin/mail_log/{{ logrow.id }}"><span class="glyphicon glyphicon-envelope"></span></a></td> -->
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

    </div>


{% endblock content %}
